#  Copyright (c) 2020 - ~, WANGXI
#  
#  GRAMMA CLASS TEST TCL FILE
#  Used in NS-2 simulator
#  Clone from https://gitee.com/WangXi_Chn/ns2_modulelib
#  Note in https://www.yuque.com/wangxi_chn/kozrfl
#  
#  Change Logs:
#  Date           Author       Notes			Mail
#  2020-12-05     WangXi   	   first version	WangXi_Chn@foxmail.com

Class mom

mom instproc greet {} {
    $self instvar age_
    puts "$age_ year old mom say:
    How are you doing?"
}

Class kid superclass mom

kid instproc gitee {} {
    $self instvar age_
    puts "$age_ year old kid say:
    What's up,dude?"
}

set a [new mom]
$a set age_ 45
set b [new kid]
$b set age_ 15

$a greet
$b greet

# namespace style 1---------------------------
namespace eval Counter {
    variable num 0
    proc Bump {} {
        variable num
        return [incr num]
    }
}

# add a process
namespace eval Counter {
    proc test {args} {
        return $args
    }
}

# delete test process
namespace eval Counter {
    rename test ""
}

Counter::Bump
puts $::Counter::num

# namespace style 2---------------------------
namespace eval MyMath {
  # Create a variable inside the namespace
  variable myResult
}

# Create procedures inside the namespace
proc MyMath::Add {a b } {  
  set ::MyMath::myResult [expr $a + $b]
}
MyMath::Add 10 23

puts $::MyMath::myResult

#/************************ (C) COPYRIGHT 2020 WANGXI **************END OF FILE****/
